//
//  StartController.m
//  吃货·上海
//
//  Created by 高青松 on 15/12/1.
//  Copyright © 2015年 濮亚军. All rights reserved.
//

#import "StartController.h"
#import "MainController.h"
@interface StartController ()

@property(nonatomic, strong)UIScrollView *startScrollView;      // 引导界面ScrollView
@property(nonatomic, strong)UIPageControl *page;                // 小点

@end

@implementation StartController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.startScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight)];
    //    self.startScrollView.delegate = self;
    self.startScrollView.contentSize = CGSizeMake(KScreenWidth * 3, KScreenHeight);
    self.startScrollView.contentOffset = CGPointMake(KScreenWidth * 0, 0);
    self.startScrollView.pagingEnabled = YES;
    self.startScrollView.bounces = NO;
    self.startScrollView. showsHorizontalScrollIndicator = NO;
    self.startScrollView.showsVerticalScrollIndicator = NO;
    [self.view addSubview:_startScrollView];
    
    UIImageView *startImage1 = [[UIImageView alloc] initWithFrame:CGRectMake(KScreenWidth * 0, 0, KScreenWidth, KScreenHeight)];
    startImage1.image = [UIImage imageNamed:@"fisrt"];
    [self.startScrollView addSubview:startImage1];
    
    UIImageView *startImage2 = [[UIImageView alloc] initWithFrame:CGRectMake(KScreenWidth * 1, 0, KScreenWidth, KScreenHeight)];
    startImage2.image = [UIImage imageNamed:@"second"];
    [self.startScrollView addSubview:startImage2];
    
    UIImageView *startImage3 = [[UIImageView alloc] initWithFrame:CGRectMake(KScreenWidth * 2, 0, KScreenWidth, KScreenHeight)];
    startImage3.userInteractionEnabled = YES;
    startImage3.image = [UIImage imageNamed:@"third"];
    [self.startScrollView addSubview:startImage3];
    
    UIView *tapView = [[UIView alloc] initWithFrame:CGRectMake(0, KScreenHeight - (KScreenHeight / 5), KScreenWidth, KScreenHeight / 5)];
    //    tapView.backgroundColor = [UIColor redColor];
    [startImage3 addSubview:tapView];
    
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAction:)];
    [tapView addGestureRecognizer:tap];
    
    
}

- (void)tapAction:(UITapGestureRecognizer *)tap
{
    NSLog(@"----");
    // 说明在最后一张引导图上了
    if (self.startScrollView.contentOffset.x == KScreenWidth * 2)
    {
        // 保存状态
        [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"isStart"];
        
        MainController *mainViewVc = [[MainController alloc]init];
        UINavigationController *mainNav = [[UINavigationController alloc]initWithRootViewController:mainViewVc];
    
        [self presentViewController:mainNav animated:NO completion:nil];
        
    }
}


    


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
